﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HPPUtil.Helpers
{
    public static class IEnumerableExtension
    {
        public static IEnumerable<TResult> Cast<T,TResult>(this IEnumerable<T> sources, Func<T, TResult> changeFunc)
        {
            if (changeFunc == null)
            {
                return null;
            }

            List<TResult> results = new List<TResult>(sources.Count());

            foreach (T source in sources)
            {
                results.Add(changeFunc(source));
            }

            return results;
        }
    }
}
